import Vue from 'vue'
import App from './App.vue'
import 'babel-polyfill'
import router from './router'
import store from './store/index'
import {
  defaultNodeAddress
} from './store/state'
import './assets/css/reset.css'
import ElementUI from './config/elementConfig'
import VueClipboard from 'vue-clipboard2'
import i18n from './config/i18n'
import locale from 'element-ui/lib/locale' //locale兼容
import Chain33Rpc from 'chain33-rpc-api'
import filters from '@/utils/filters.js'
import './config/mintConfig'

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueClipboard)

// 注册 查询区块链的接口
Vue.prototype.Rpc = new Chain33Rpc(defaultNodeAddress, null, (error) => {
  if (error.message === 'Failed to fetch') {
    // 挂节点处理
  }
  throw error
})

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]) //注册全局filter；
})

locale.i18n((key, value) => i18n.t(key, value)) //为了兼容element插件的多语言切换
// 定义全局点击函数
Vue.prototype.globalClick = function (callback) {
  document.getElementById('app').onclick = function () {
    callback();
  };
};

new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')